import axios from 'axios'

const SUCCESS = 200
const HTTP_FAILURE = 'http failure'


// 统一请求路径前缀，这个是后台接口地址
var BASE_URL = 'http://127.0.0.1:9091';

 
const instance = axios.create({
  baseURL: BASE_URL,
  timeout: 15000,
  withCredentials: true,
  headers: {
    "Access-Control-Allow-Origin"  : "*",
    "Access-Control-Allow-Methods" : "POST, GET, OPTIONS, PUT, DELETE",
    "Access-Control-Allow-Headers" : "access-control-allow-headers,access-control-allow-methods,access-control-allow-origin,content-type"
  }
});

const axiosGet = url => {
  return instance.get(url)
}

const axiosPost = (url, param) => {
  return instance.post(url, param)
}

const axiosUpload = (url, data) => {
  return axios.postForm(url, data, { baseURL : BASE_URL })
}

export const search = (param) => axiosPost('/search/searchFindAll', param)
export const upload = (data) => axiosUpload('/fileManagement/uploadFile', data)